package com.hisysteTopet.hisystepet.mapper.provider;

import com.hisysteTopet.hisystepet.bean.Pet;
import com.hisysteTopet.hisystepet.bean.PetLifeGoods;
import org.apache.ibatis.jdbc.SQL;

public class updatePetLifeGoodsMessage extends SQL{

    // 动态sql，比xml好用，xml太烦了，后期学习，维修老项目还要用到
    public String updatePetLifeGoodsMessage(PetLifeGoods petLifeGoods) {
        return new SQL(){{
            UPDATE("pet_life_goods");
            if(petLifeGoods.getIntroduce() != null) {
                SET("introduce = #{introduce}");
            }
            if(petLifeGoods.getPriceName() != null) {
                SET("price_name = #{priceName}");
            }

            if(petLifeGoods.getPrice() != null) {
                SET("price = #{price}");
            }

            WHERE("price_id = #{priceId}");

        }}.toString();
    }

}
